package com.xtaller.lazy.config.aop;

import cn.yueshutong.springbootstartercurrentlimiting.handler.CurrentInterceptorHandler;
import com.xtaller.lazy.lib.convert.J;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @version V1.0
 * @author: Taller
 * @date: 2019-04-23
 * @Description: 全局限流拦截
 */
@Component
public class LimiterGlobalAspect implements CurrentInterceptorHandler {
    @Override
    public void preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        response.setHeader("Content-type", "text/html;charset=UTF-8");
        response.setStatus(429);
        response.getWriter().write(J.s2r("当前服务器限流 code:1001"));
    }
}
